package com.deco.service.store;

import java.util.Date;
import java.util.List;

import com.deco.dao.domain.table.StoreShop;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.deco.domain.vo.fix.FixTypeVo;
import com.deco.domain.vo.store.StoreShopVo;
import com.deco.logic.fix.FixTypeLogic;
import com.deco.logic.store.StoreShopLogic;
import com.deco.service.CommonService;
import com.free.common.vo.PageResponseVo;
import com.free.common.vo.PageSearchVo;
import com.free.common.vo.ResultModel;

@Service
public class StoreShopService extends CommonService {
	   /*========================================================================*
     *                         Public Fields (公共属性)
     *========================================================================*/

    /*========================================================================*
     *                         Private Fields (私有属性)
     *========================================================================*/
    
    @Autowired
    private StoreShopLogic storeShopLogic;
    /*========================================================================*
     *                         Construct Methods (构造方法)
     *========================================================================*/

    /*========================================================================*
     *                         Public Methods (公有方法)
     *========================================================================*/

    
    public StoreShopVo getStoreShop(int id){
    	return storeShopLogic.getStoreShop(id);
    }
    
    public ResultModel save(StoreShopVo storeShopVo){
    	Date current = new Date();
		int currentUserId = getCurrentUserId();
    	if(storeShopVo.getId() == null || storeShopVo.getId() == 0L){
    		storeShopVo.setCreateBy(currentUserId);
    		storeShopVo.setCreateTime(current);
    		storeShopVo.setUpdateBy(currentUserId);
    		storeShopVo.setUpdateTime(current);
    		storeShopLogic.create(storeShopVo);
    	}
    	else{
    		storeShopVo.setUpdateBy(currentUserId);
    		storeShopVo.setUpdateTime(current);
    		storeShopLogic.update(storeShopVo);
    	}
    	return ResultModel.success();
    }

	public ResultModel delete(int id) {
		storeShopLogic.delete(id);
	  	return ResultModel.success();
	}

	public PageResponseVo<StoreShopVo> pageInfo(
			PageSearchVo<StoreShopVo> condition) {
		return storeShopLogic.getPageInfo(condition);
	}

	public ResultModel batchDelete(Integer[] ids) {
		if(ids == null || ids.length == 0){
    		return ResultModel.success();
		}
    	int res = storeShopLogic.batchDelete(ids);
    	if(res > 0){
    		return ResultModel.success();
		}
		return ResultModel.failure();
	}

	public List<StoreShopVo> queryProvList(Integer type) {
		// TODO Auto-generated method stub
		return storeShopLogic.queryProvList(type);
	}

	public List<StoreShopVo> queryCityList(Integer type, String prov){
    	return storeShopLogic.queryCityList(type,prov);
	}

	public List<StoreShopVo> queryAreaList(Integer type, String city){
		return storeShopLogic.queryAreaList(type,city);
	}

	public List<StoreShopVo> queryStoreShop(StoreShopVo shop) {
		return storeShopLogic.queryStoreShop(shop);
	}


    /*========================================================================*
     *                         Private Methods (私有方法)
     *========================================================================*/

}
